﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Observer_C_Shaper_
{
    class CurrentCondition : IObserver<Data> {
        private IDisposable unsubscriber;

        public virtual void Subscribe(IObservable<Data> provider) {
            if(provider != null) {
                unsubscriber = provider.Subscribe(this);
            }
        }

        public void OnNext(Data value) {
           Console.WriteLine("Current Condition: " + value.Temperature + "F degrees and" + value.Humidity + "% humidity");
        }

        public void OnError(Exception error) {
            //throw new NotImplementedException();
        }

        public void OnCompleted() {
            this.Unsubscribe();
        }

        public virtual void Unsubscribe() {
           unsubscriber.Dispose();
        }
    }
}
